package beans;

import entities.Prenotazioni;
import controllers.PrenotazioniFacade;
import java.io.Serializable;
import java.util.ResourceBundle;
import javax.annotation.PostConstruct;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
import javax.inject.Inject;
import javax.faces.view.ViewScoped;

@Named(value = "prenotazioniController")
@ViewScoped
public class PrenotazioniController extends AbstractController<Prenotazioni> implements Serializable {

    @Inject
    private PrenotazioniFacade ejbFacade;

    public PrenotazioniController() {
        super(Prenotazioni.class);
    }

    @PostConstruct
    public void init() {
        super.setFacade(ejbFacade);
    }
    
    @Override
     public void saveNew(ActionEvent event) {
        super.selected.setAccettato(true);
        super.selected.setIdPrenotazione(Integer.MIN_VALUE);
        String msg = ResourceBundle.getBundle("/MyBundle").getString(itemClass.getSimpleName() + "Created");
        persist(AbstractController.PersistAction.CREATE, msg);
        if (!isValidationFailed()) {
            items = null; // Invalidate list of items to trigger re-query.
        }
    }

}
